package work2;

import Uti.ScannerUti;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Collections;

public class MyDate {
    int year;
    int month;
    int day;
    int hour;
    int minute;
    int second;

    public MyDate() {
        System.out.println("输入年份：");
        this.year = ScannerUti.getInt();
        System.out.println("输入月份：");
        this.month = ScannerUti.getMonth();

    }
    public void printDate(){
        System.out.println("----------"+year+"年"+month+"月"+"----------");
        LocalDate firstDayOfMonth = LocalDate.of(year,month,1);
        String firstDay = firstDayOfMonth.getDayOfWeek().toString().toLowerCase();
        ArrayList<String> list=new ArrayList<>();
        Collections.addAll(list,"monday","tuesday","wednesday","thursday","friday","saturday","sunday");
        System.out.println("一\t二\t三\t四\t五\t六\t日");
        int star = list.indexOf(firstDay);
        for(int i=0;i<star;i++) System.out.print(" \t");
        for (int i=star+1;i<=star+firstDayOfMonth.lengthOfMonth();i++){
            System.out.print(i-star+"\t");
            if(i%7==0) System.out.println();
        }
        System.out.println();
    }

    public MyDate(int year, int month, int day, int hour, int minute, int second) {
        this.year = year;
        this.month = month;
        this.day = day;
        this.hour = hour;
        this.minute = minute;
        this.second = second;
    }

    /**
     * 获取
     * @return year
     */
    public int getYear() {
        return year;
    }

    /**
     * 设置
     * @param year
     */
    public void setYear(int year) {
        this.year = year;
    }

    /**
     * 获取
     * @return month
     */
    public int getMonth() {
        return month;
    }

    /**
     * 设置
     * @param month
     */
    public void setMonth(int month) {
        this.month = month;
    }

    /**
     * 获取
     * @return day
     */
    public int getDay() {
        return day;
    }

    /**
     * 设置
     * @param day
     */
    public void setDay(int day) {
        this.day = day;
    }

    /**
     * 获取
     * @return hour
     */
    public int getHour() {
        return hour;
    }

    /**
     * 设置
     * @param hour
     */
    public void setHour(int hour) {
        this.hour = hour;
    }

    /**
     * 获取
     * @return minute
     */
    public int getMinute() {
        return minute;
    }

    /**
     * 设置
     * @param minute
     */
    public void setMinute(int minute) {
        this.minute = minute;
    }

    /**
     * 获取
     * @return second
     */
    public int getSecond() {
        return second;
    }

    /**
     * 设置
     * @param second
     */
    public void setSecond(int second) {
        this.second = second;
    }

    public String toString() {
        return "work2.MyDate{year = " + year + ", month = " + month + ", day = " + day + ", hour = " + hour + ", minute = " + minute + ", second = " + second + "}";
    }
}
